// vite.config.js
import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import jsx from '@vitejs/plugin-vue-jsx'
import dts from 'vite-plugin-dts'

export default defineConfig({
  publicDir: false,
  build: {
    lib: {
      // Could also be a dictionary or array of multiple entry points
      // entry: {
      //   button: resolve(__dirname, 'package/pc/button/index.js'),
      //   link: resolve(__dirname, 'package/pc/link/index.jsx'),
      //   loading: resolve(__dirname, 'package/pc/loading/index.jsx'),
      // },
      entry: resolve(__dirname, 'packages/pc/index.js'),
      formats: ['es'],
      // fileName: '[name]/index',
    },
    rollupOptions: {
      // 确保外部化处理那些你不想打包进库的依赖
      external: ['vue'],
      output: {
        // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
        globals: {
          vue: 'Vue',
        },
      },
    },
  },
  plugins: [
    vue({
      preprocessStyles: true,
    }),
    jsx(),
    // 自动构建.d.ts
    // dts({
    //     insertTypesEntry: true,
    //     copyDtsFiles: true
    // })
  ]
})